package com.instanceofdemo;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class InstanceOfDemo {
	public static final void main(String [] arg){
		
		Base base=new Base();
		Child child=new Child();
		if(child instanceof Base){
			System.out.println("instance of  base class");
		}
		if(child instanceof Interface){
			System.out.println("instance of inferface");
		}
		
		int size=100;
		if(size<0){
			System.out.println("<0");
		}else if(size>30){
			System.out.println(">30");
		}else{
			System.out.println("else");
		}
		String time="123";
		System.out.println(getTime("MM-dd",Long.parseLong(time)));
		
		List<String> a =new ArrayList<>();
		a.add("a1");
		a.add("a2");
		List<String> b =new ArrayList<>();
		b.add("b1");
		b.add("b2");
		List<String> c =new ArrayList<>();
		c.addAll(a);
		c.addAll(b);
		for (int i = 0; i < c.size(); i++) {
			System.out.println(c.get(i));
		}
		
	}
	public static String getTime(String pattern,long time) {
	    SimpleDateFormat format = new SimpleDateFormat(pattern);
	    Date d1 = new Date(time);
	    return format.format(d1);
	}

	class Inner{}
}

interface Interface{}
class Child extends Base implements Interface{
	
}